#include<iostream>
typedef long long ll;
const int N = 1e6 + 10;
ll a[N];
using namespace std;
int main()
{
	int t;cin >> t;
	while (t--)
	{
		ll a, b, x, y, sum = 0;cin >> x >> y >> a >> b;
		ll t1 = max(x, y);
		ll t2 = min(x, y);
		if (2 * a <= b)
		{
			sum += t2 * 2 * a;
			sum += (t1 - t2) * a;
		}
		else
		{
			sum += t2 * b;
			sum += (t1 - t2) * a;
		}
		cout << sum << endl;
	}
	return 0;
}
// 1             3                  4          5
// 391       555                2          6

// 1           3					  4           5
//555       391                6			   2